using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ivory;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using X13;
using X13.Player;

namespace Sweeper
{
    public static partial class Globals
    {
        public static bool DrawWireFrame = false;
        public static bool EnableCulling = false;
    }

    public class Launcher : Microsoft.Xna.Framework.Game
    {
        //Fields
        private ScreenManager _Manager;

        //Constuct
        public Launcher()
        {
            this.Content.RootDirectory = "Content";
            ObjectHolder.ParentGame = this;
            _Manager = new ScreenManager(this, "data/config.cfg");
        }

        protected override void Initialize()
        {
            _Manager.SetMainMenu(new MainMenu(this));
            _Manager.AddGameScreen(RenderTest01.Key, new RenderTest01(this));
            _Manager.AddGameScreen(RenderTest02.Key, new RenderTest02(this));

            base.Initialize();
        }
        protected override void LoadContent()
        {
            ObjectHolder.Load(this);
            Resources.LoadData(this);
            _Manager.LoadScreenManager();
        }
     
        protected override void Update(GameTime gameTime)
        {
            _Manager.Update(gameTime);

            base.Update(gameTime);
        }
        protected override void Draw(GameTime gameTime)
        {
            RasterizerState rs = new RasterizerState();
            rs.FillMode = Globals.DrawWireFrame ? FillMode.WireFrame : FillMode.Solid;
            rs.CullMode = Globals.EnableCulling ? CullMode.CullCounterClockwiseFace : CullMode.None;

            DepthStencilState ds = new DepthStencilState();
            ds.DepthBufferEnable = true;

            GraphicsDevice.RasterizerState = rs;
            GraphicsDevice.DepthStencilState = ds;
            GraphicsDevice.Clear(Color.DarkSlateBlue);

            _Manager.Draw(gameTime);
            base.Draw(gameTime);
        }
    }
}
